//
//  UIImage+GG.m
//  unzip
//
//  Created by yg on 2021/11/16.
//

#import "UIImage+GG.h"

@implementation UIImage (GG)

- (UIImage *)gg_setSize:(CGSize)size scale:(CGFloat)scale{
	return [self gg_setSize:size scale:scale orientation:UIImageOrientationUp];
}

- (UIImage *)gg_setSize:(CGSize)size scale:(CGFloat)scale orientation:(UIImageOrientation)orientation{
	if (scale < 1) {
		scale = 1;
	}
	UIGraphicsBeginImageContext(size);
	[self drawInRect:CGRectMake(0, 0, size.width, size.height)];
	UIImage * newImage = UIGraphicsGetImageFromCurrentImageContext();
	UIGraphicsEndImageContext();
	newImage = [UIImage imageWithCGImage:newImage.CGImage scale:scale orientation:orientation];
	return newImage;
}

- (BOOL)gg_saveToPath:(NSString *)path{
	BOOL result = [UIImagePNGRepresentation(self) writeToFile:path  atomically:YES];
	return result;
}

@end
